// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vant from 'vant'
import 'vant/lib/index.css'
import App from './App'
import router from './router'
import '@/assets/css/index.css'
import store from './vuex/store'
import Mock from '@/mock'

Vue.use(Vant)
Vue.config.productionTip = false

/* mockjs */
Mock.mockData()

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})

router.afterEach((to, from) => {
  if (!from.name) {
    if (sessionStorage.getItem('deskInfo')) {
      store.dispatch('putDeskInfo', sessionStorage.getItem('deskInfo'))
    }
    if (sessionStorage.getItem('finalMenu')) {
      store.dispatch('putFinalMenu', JSON.parse(sessionStorage.getItem('finalMenu')))
    }
    if (sessionStorage.getItem('recommendMenu')) {
      store.dispatch('putRecommendMenu', JSON.parse(sessionStorage.getItem('recommendMenu')))
    }
  }
  // console.log(store.state.deskItem.finalMenu)
  console.log(store.state.deskRecommendItem.recommendMenu)
})
